package com.example.medicine.controller;


import com.example.medicine.Bean.dilixinxi;
import com.example.medicine.Mapper.dlxxMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping(value="/dlxx")
public class DlxxController {
    @Autowired
    private dlxxMapper dlxxMapper;

    /**
     * 接收传值请求，返回地理信息json
     */
    @GetMapping("/")
    public List<dilixinxi> getDlxxList() {
        // 从数据库中获取数据
        return dlxxMapper.getAll();
    }

    /**
     * 接收新建请求，向dlxx表中插入数据
     */
    @PostMapping("/")
    public void insertDlxx(@RequestBody dilixinxi dlxx){dlxxMapper.insert(dlxx);}

    /**
     * 接收更新请求，根据id值更新dlxx表内容
     */
    @PutMapping("/")
    public void updateDlxx(@RequestBody dilixinxi dlxx){
        dlxxMapper.update(dlxx);
    }

    @DeleteMapping("/{id}")
    public void deleteDlxx(@PathVariable int id){
        dlxxMapper.deleteById(id);
    }
}
